import {
	baseUrl
} from './config.js'
const request = (config) => {
	// 处理 apiUrl
	config.url = baseUrl + config.url;
	if (!config.data) {
		config.data = {};
	}
	if (!config.method) {
		config.method = 'GET'
	}
	if (!config.header) {
		config.header = null
	}
	return new Promise(function(resolve, reject) {
		uni.request({
			url: config.url,
			method: config.method,
			data: config.data,
			header: config.header,
			success(res) {
				resolve(res.data)
			},
			fail(err) {
				reject(err)
			}
		})
	})
};
export default request;